<template>
	<view class="news">
		<news-list @newClick="newClick" :newsList="newList"></news-list>
	</view>
</template>

<script>
	import NewsList from '@/components/newList.vue'
	export default {
		data() {
			return {
				newList: []
			}
		},
		components: {
			NewsList
		},
		created() {
			this.getNewList()
		},
		methods: {
			async getNewList() {
				const res = await this.$http({
					url: '/getnewslist'
				})
				if(res.statusCode !== 200) return uni.showToast({
					title: '获取数据失败'
				})
				this.newList = res.data.message
			},
			// 监听子组件点击传值
			newClick(id) {
				uni.navigateTo({
					url: '/pages/new-detail/new-detail?id='+id
				})
			}
		}
	}
</script>

<style lang="scss">
	
</style>
